package com.amap.search.controller;

import com.amap.search.entity.es.PoiRecordEs;
import com.amap.search.entity.vo.PoiRequest;
import com.amap.search.service.ElasticSearchQueryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/poi")
@Api(tags = "poi数据查询接口")
public class PoiSearchController {
    @Resource
    private ElasticSearchQueryService queryService;

    @ApiOperation("简单查询")
    @GetMapping("/search/simple")
    public List<PoiRecordEs> simpleQuery(@RequestParam("queryStr") String queryStr){
        System.out.println("查询字符串为 ： " + queryStr);
        return queryService.simpleQuery(queryStr);
    }

    @ApiOperation("多条件精准查询")
    @PostMapping("/search/precise")
    public List<PoiRecordEs> preciseQuery(@RequestBody PoiRequest request){
        return queryService.queryPoiInfo(request);
    }

    // todo: 根据给出的经纬度，寻找附近的景点
    @PostMapping("/search/place")
    @ApiOperation("经纬度查询")
    public List<PoiRecordEs> placeQuery(){
        return null;
    }
}
